package com.indusfo.spc.controller;

import com.indusfo.spc.pojo.PlanBom;
import com.indusfo.spc.service.PlanBomService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author: 熊冰
 * @Date: 2019/11/9 13:12
 * 任务单流程关键物料
 */

@Controller
@RequestMapping("/planBom")
public class PlanBomController {
	@Autowired
	private PlanBomService planBomService;

	//查询
	@RequestMapping(value="/queryPlanBom")
	@ResponseBody
	public JSONObject queryPlanBom(PlanBom planBom) {
		JSONObject json = planBomService.queryPlanBom(planBom);
		return json;
	}

	//新增
	@RequestMapping(value="/insertPlanBom", method= RequestMethod.POST)
	@ResponseBody
	public JSONObject insertPlanBom(PlanBom planBom) {
		JSONObject json = planBomService.insertPlanBom(planBom);
		return json;
	}

	//修改
	@RequestMapping(value = "/updatePlanBom",method= RequestMethod.POST)
	@ResponseBody
	public JSONObject updatePlanBom (PlanBom planBom){
		JSONObject json=planBomService.updatePlanBom(planBom);
		return json;
	}

	//删除
	@RequestMapping(value="/deletePlanBom", method= RequestMethod.POST)
	@ResponseBody
	public JSONObject deletePlanBom(@RequestParam("planBomIds") List<Integer> planBomIds, Integer dataState) {
		dataState = 2;
		JSONObject json = planBomService.deletePlanBom(planBomIds, dataState);
		return json;
	}

	//启用
	@RequestMapping(value="/startPlanBom", method= RequestMethod.POST)
	@ResponseBody
	public JSONObject startPlanBom(@RequestParam("planBomIds") List<Integer> planBomIds, Integer dataState) {
		dataState = 2;
		JSONObject json = planBomService.deletePlanBom(planBomIds, dataState);
		return json;
	}

	//停用
	@RequestMapping(value="/stopPlanBom", method= RequestMethod.POST)
	@ResponseBody
	public JSONObject stopPlanBom(@RequestParam("planBomIds") List<Integer> planBomIds, Integer dataState) {
		dataState = 2;
		JSONObject json = planBomService.deletePlanBom(planBomIds, dataState);
		return json;
	}





}

